﻿package mortal.game.resource.info.item
{
    import Message.Public.*;
    import com.gengine.utils.*;
    import mortal.common.tools.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;

    public class ItemInfo extends Object
    {
        public var code:int;
        public var icon:String;
        public var dropIcon:String;
        public var codeUnbind:int;
        public var name:String;
        public var group:int;
        public var category:int;
        public var type:int;
        public var level:int;
        public var itemLevel:int;
        public var effect:int;
        public var effectEx:int;
        public var career:int;
        public var bind:int;
        public var sell:int;
        public var sellPrice:int;
        public var sellUnit:int;
        public var color:int;
        public var overlay:int;
        public var cdTime:int;
        public var useType:int;
        public var descStr:String;
        public var feedMount:int;
        public var hunqiFeed:int;
        public var market:int;
        public var beginTime:String;
        public var endTime:String;
        public var skill:String;
        public var canDecompose:int;
        public var decomposeItems:String;
        public var decomposeRandomNum:int;
        public var broadcastWorldlevel:int;
        public var prescription:int;
        public var existTime:int;
        private var _beginDate:Date;
        private var _endDate:Date;

        public function ItemInfo()
        {
            return;
        }// end function

        public function get url() : String
        {
            return this.icon + ".jpg";
        }// end function

        public function getExtendAtt(param1:String)
        {
            return this[param1];
        }// end function

        public function get beginDate() : Date
        {
            if (!this._beginDate)
            {
                if (this.beginTime)
                {
                    this._beginDate = DateParser.strToDateNormal(this.beginTime);
                }
            }
            return this._beginDate;
        }// end function

        public function get endDate() : Date
        {
            if (!this._endDate)
            {
                if (this.endTime)
                {
                    this._endDate = DateParser.strToDateNormal(this.endTime);
                }
            }
            return this._endDate;
        }// end function

        public function alyDesc() : String
        {
            var _loc_1:int = 0;
            var _loc_2:String = null;
            var _loc_3:ItemGiftBagInfo = null;
            var _loc_4:int = 0;
            var _loc_5:Array = null;
            var _loc_6:ItemGiftBagInfo = null;
            var _loc_7:Array = null;
            var _loc_8:Array = null;
            var _loc_9:int = 0;
            var _loc_10:ItemInfo = null;
            var _loc_11:String = null;
            var _loc_12:int = 0;
            var _loc_13:int = 0;
            if (this.descStr)
            {
                _loc_1 = int(this.descStr);
                if (_loc_1 > 0)
                {
                    this.descStr = DescConfig.instance.getDescAlyzObj(_loc_1, this);
                }
                _loc_2 = this.descStr;
                if (this.group == EGroup._EGroupProp && this.category == EProp._EPropGiftBag)
                {
                    _loc_3 = this as ItemGiftBagInfo;
                    if ((this as ItemGiftBagInfo).set > 0)
                    {
                        _loc_4 = Cache.instance.role.roleInfo.level;
                        _loc_5 = ItemConfig.instance.itemGiftSetDic[(this as ItemGiftBagInfo).set];
                        for each (_loc_6 in _loc_5)
                        {
                            
                            if (_loc_4 >= int(_loc_6.levelMin) && _loc_4 <= int(_loc_6.levelMax))
                            {
                                _loc_3 = _loc_6;
                                break;
                            }
                        }
                    }
                    _loc_2 = _loc_3.descStr;
                    if (_loc_2.indexOf("<item>") >= 0 && (_loc_3.itemList1 || _loc_3.itemList2))
                    {
                        _loc_7 = _loc_3.itemList1.split("&");
                        if (_loc_3.itemList2)
                        {
                            _loc_7 = _loc_7.concat(_loc_3.itemList2.split("&"));
                        }
                        _loc_8 = [];
                        _loc_9 = _loc_7.length;
                        while (_loc_12 < _loc_9)
                        {
                            
                            if (_loc_7[_loc_12])
                            {
                                _loc_8 = (_loc_7[_loc_12] as String).split("#");
                                _loc_11 = "\n";
                                if (_loc_8[0] == 3)
                                {
                                    _loc_10 = ItemConfig.instance.getConfig(int(_loc_8[1]));
                                    _loc_13 = _loc_10.category;
                                    if (_loc_10.group == EGroup._EGroupProp && _loc_10.itemLevel && (_loc_13 == EProp._EPropFashionClothesEquip || _loc_13 == EProp._EPropPetEquip || _loc_13 == EProp._EPropMountEquip || _loc_13 == EProp._EPropFashionWingEquip || _loc_13 == EProp._EPropFashionWeaponEquip || _loc_13 == EProp._EPropFashionFightSoulEquip || _loc_13 == EProp._EPropFashionFightMethodEquip || _loc_13 == EProp._EPropFashionDragonSoulEquip || _loc_13 == EProp._EPropFashionHolyBookEquip || _loc_13 == EProp._EPropFashionWarShieldEquip || _loc_13 == EProp._EPropFashionMonsterSoulEquip))
                                    {
                                        _loc_2 = _loc_2 + (_loc_11 + _loc_10.htmlName + "[+" + _loc_10.itemLevel + "]*" + _loc_8[2]);
                                    }
                                    else
                                    {
                                        _loc_2 = _loc_2 + (_loc_11 + _loc_10.htmlName + "*" + _loc_8[2]);
                                    }
                                }
                                else if (_loc_8[0] == 2)
                                {
                                    _loc_2 = _loc_2 + (_loc_11 + GameDefConfig.instance.getEPrictUnitName(_loc_8[1]) + "*" + _loc_8[2]);
                                }
                            }
                            _loc_12++;
                        }
                    }
                }
            }
            return _loc_2;
        }// end function

        public function get normalTooltip() : String
        {
            return "";
        }// end function

        public function get tooltip1() : String
        {
            return "";
        }// end function

        public function get tooltip2() : String
        {
            return "";
        }// end function

        public function get htmlName() : String
        {
            return HTMLUtil.addColor(this.name, this.colorStr);
        }// end function

        public function get colorStr() : String
        {
            return ColorConfig.instance.getItemColorString(this.color);
        }// end function

        public function clone() : ItemInfo
        {
            var _loc_1:* = new ItemInfo();
            ClassTypesUtil.copyClassValue(_loc_1, this, false);
            return _loc_1;
        }// end function

    }
}
